﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace JFLogic.Utils
{
    public class Log
    {
        public static void PrintLog(string log)
        {
            string path = System.Configuration.ConfigurationManager.AppSettings["BasePath"] + "Log\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            log = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffffff") + ":" + log + "\r\n";
            try
            {
                string fileName = path + DateTime.Now.ToString("yyyyMMdd") + ".log";
                using (FileStream fileStream = new FileStream(fileName, FileMode.Append))
                {
                    StreamWriter writer = new StreamWriter(fileStream);
                    writer.Write(log);
                    writer.Flush();
                    writer.Close();
                    fileStream.Close();
                }
            }
            catch 
            {
                //throw ex;
            }

            Console.WriteLine(log);
        }
    }
}
